package dmp.agent;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class UrlFilterJob2  {
	public static void main(String[] args) throws Exception {
		Configuration conf=new Configuration();
		conf.set("mapreduce.job.queuename", "ven1"); //设置队列
		Job job = Job.getInstance(conf);
		
		job.setJobName("urlfilter");
		job.setJarByClass(UrlFilterJob2.class);
		
		job.setMapperClass(UrlFilterMap.class);
		job.setReducerClass(UrlFilterReduce.class);
		
		job.setMapOutputKeyClass(Text.class);
		job.setMapOutputValueClass(Text.class);
		
		job.setOutputKeyClass(Text.class);
		job.setOutputValueClass(Text.class);
		
		SequenceFileInputFormat.setInputPaths(job, new Path(args[0]));
		job.setInputFormatClass(SequenceFileInputFormat.class);
		
		
		Path out=new Path(args[1]);
		FileOutputFormat.setOutputPath(job, out);
		
		FileSystem fs=FileSystem.get(new Configuration());
		if(fs.exists(out)){
			fs.delete(out, true);
		}
		
		job.waitForCompletion(true);
		
	}
}

